<?php
include('top.php');
require_once('pasmy/dbwaarden.php');
/*echo "dbhost = $dbhost<br>";*/
echo "<br><br>";
$mysql_id = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($db, $mysql_id);

/* prijs routine begin*/

$prijs = $_POST['prix'];
/*echo "prijs = $prijs<br>";*/
if(isset($_POST["prix"])){
	/*foreach($_POST as $sleutel => $waarde) {
		echo "sleutel = $sleutel en waarde = $waarde <br>";
		}*/
$afstand = explode("-",$_POST["kilom"]);
$km1 = $afstand[0];
$km2 = $afstand[1];
$aantalpaletten = $_POST["pals"];
/*echo "paletten = $aantalpaletten<br>";*/	
$metervloer = $_POST["lengte"];

/*echo "meter vloer = $metervloer<br>";*/
if($metervloer == "-----" AND $_POST["kilom"] == "-----" AND $_POST["pals"] == "-----") {?> <META http-equiv="Refresh" content="0"; URL=index.php><?php exit;}
if($metervloer == "-----" AND $_POST["pals"] == "-----") {?><META http-equiv="Refresh" content="0"; URL=index.php><?php exit;}

if($metervloer == "-----") {

	$sql = "SELECT prix FROM `marquette` WHERE `km1` >= $km1 AND `km2` <= $km2 AND `pal` = $aantalpaletten";
}
else {
	$sql = "SELECT prix FROM `marquette` WHERE `km1` >= $km1 AND `km2` <= $km2 AND `mp` = $metervloer";
	}
	
/*echo "sql = $sql<br>";*/
 
$res = mysql_query($sql, $mysql_id);
while ($row = mysql_fetch_row($res)) {
	$prijsvraag = $row[0];
	}
mysql_free_result($res);
$retourprijs = $prijsvraag - ($prijsvraag * 0.30);
?>
<table align="center" border="1" width="50%">
<tr><td><div style="text-align: center"><h3><font color="black">Prix &agrave; demander Aller</font></h3></div></td></tr>
<tr><td><div style="text-align: center"><h3><font color="red"><?php echo $prijsvraag;?> &euro;</font></h3></div></td></tr>
<tr><td><div style="text-align: center"><h3><font color="black">Prix &agrave; demander Retour</font></h3></div></td></tr>
<tr><td><div style="text-align: center"><h3><font color="red"><?php echo round($retourprijs,2);?> &euro; </font></h3></div></td></tr>
</table>
<?php
 
}
	
else {

/* prijs routine eind */


$kilometers = array('-----','1-25','26-50','51-75','76-100','101-130','131-170','171-210','210-280','281-999');
$paletten = array('-----','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20');
$meters = array('-----','0.40','0.80','1.20','1.60','2.00','2.40','2.80','3.20','3.60','4.00','4.40','4.80','5.20','5.60','6.00','6.40','6.80','7.20','7.60','8.00');

?>
<form action="marquette.php" method="post">
<table width="75%" align="center" border="1">
<tr>
<td colspan="3"><div style="text-align: center"><h3><font color="black">Prix Vanzeveren</font></h3></div></td>
</tr>
<tr>
<td width="25%"><div style="text-align: center"><h4><font color="black">Distance</font></h4></div></td>
<td width="25%"><div style="text-align: center"><h4><font color="black">Nombre de palettes</font></h4></div></td>
<td width="25%"><div style="text-align: center"><h4><font color="black">M&egrave;tres planch&eacute;</font></h4></div></td>
</tr>
<tr>
<td> 
<!-- <form action="marquette.php" method="post"> -->
<div style="text-align: center"><select name="kilom"> 
<?php
while(list($key, $val)=each($kilometers)) {
		 
		echo '<option value="'.$val.'">'.$val.'</option>';
}
?>
</select> </div>
 
</td>

<td><div style="text-align: center">
<select name="pals">
<?php
while(list($key, $val)=each($paletten)) {
	
		echo '<option value="'.$val.'">'.$val.'</option>';
	
}
?>
</select>
</div>
</td>
<td><div style="text-align: center">
<select name="lengte">
<?php
while(list($key, $val)=each($meters)) {
	if (isset($lengte) && ($lengte == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?></select>
</div></td>
</tr>
<tr><td colspan="3"><div style="text-align: center">
<input type="submit" name="prix" value="Prix &agrave; demander" />
</div>
</form>
</td></tr>
</table>
<?php
}
?>

<?php
include('footer.php');
?>